<template>
  <div class="root">
    <div class="head">
      <div class="title">{{title}}</div>
      <div class="btn-download" @click="download">下载</div>
    </div>
    <div class="content">
      <img :src="url" alt="">
    </div>
  </div>
</template>

<script>
import { saveDataUrl } from '../util'

export default {
  props: [ 'title', 'url' ],
  methods: {
    download() {
      saveDataUrl(this.url, this.title)
    }
  }
}
</script>

<style scoped>
.root {
  background-color: #fff;
  border-radius: 5px;
  box-shadow: 0 0 13px #aaa;
  overflow: hidden;
  width: 100%;
  /* height: 100%; */
}
.head {
  height: 48px;
  align-items: center;
  padding: 0 10px;
  background-color: #1B1E2B;
  color: white;
  display: flex;
}
.title {
  max-width: 60%;
  overflow: auto;
}
.btn-download {
  margin-left: auto;
  background-color: #617282;
  padding: 3px 12px;
  border-radius: 5px;
}
.content {
  white-space: pre-wrap;
  height: calc(100% - 48px);
  background-color: #fff;
  display: flex;
  justify-content: center;
  align-items: center;
}
.content img {
  max-height: 400px;
  max-width: 100%;
}
</style>
